package payroll.trans;

import payroll.Employee;
import payroll.PayrollDatabase;
import payroll.Transaction;
import payroll.classification.HourlyClassification;
import payroll.method.HoldMethod;

public class AddHourlyEmployeeTransaction_begin implements Transaction {

    private int empId;
    private String name;
    private String address;
    private double hourlyRate;

    public AddHourlyEmployeeTransaction_begin(int empId, String name, String address, double hourlyRate) {
        //TODO Auto-generated constructor stub
        this.empId = empId;
        this.name = name;
        this.address = address;
        this.hourlyRate = hourlyRate;
    }

    @Override
    public void execute() {
        Employee e = new Employee(empId, name, address); //创建雇员基本信息
        e.setPaymentClassification(new HourlyClassification(hourlyRate)); //设置它计算工资方式
        e.setPaymentMethod(new HoldMethod()); //设置领取工资的方式
        PayrollDatabase.saveEmployee(e); //将雇员传进去，保存到数据库

    }

}
